/**
 * @Author sy
 * @Date 2022/9/13
 */
public class Expe4T6 {
    public static void main(String[] args) {
        double sum = 0;
        double num = 1;

        for (int i = 1; i<= 20;i++){
            num = num *((1.0)/i);
            sum += num;
        }
        System.out.println("用for循环的结果："+sum);
        int i = 1;
        while(i <= 20){
            num = num * ((1.0)/i);
            sum += num;
            i++;
        }
        System.out.println("用while循环的结果："+sum);
    }
}
